-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FEATURE/HCMPRE-1713: PopInbox and filtering integration #2108
Conversation
📝 WalkthroughWalkthroughThis pull request introduces modifications to several files within the microplan module: Changes
Sequence DiagramsequenceDiagram
participant User
participant InboxFilterWrapper
participant PlanInbox
participant API
User->>InboxFilterWrapper: Select Facility Filter
InboxFilterWrapper->>PlanInbox: Update selectedFilter
PlanInbox->>API: Search Plans with facilityId
API-->>PlanInbox: Return Filtered Results
PlanInbox-->>User: Display Filtered Plans
Possibly related PRs
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🔇 Additional comments (3)
Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 9
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (3)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js
(6 hunks)health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js
(4 hunks)health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PopInbox.js
(14 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js (1)
Pattern **/*.js
: check
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (1)
Pattern **/*.js
: check
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PopInbox.js (1)
Pattern **/*.js
: check
📓 Learnings (2)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js (1)
Learnt from: rachana-egov
PR: egovernments/DIGIT-Frontend#1847
File: health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js:308-314
Timestamp: 2024-11-18T04:35:51.535Z
Learning: In `PlanInbox.js`, the variable `planWithCensus?.StatusCount[selectedFilter]` is always defined in the given context, so null checks are unnecessary.
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (1)
Learnt from: Ramkrishna-egov
PR: egovernments/DIGIT-Frontend#1562
File: health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js:57-57
Timestamp: 2024-11-12T10:40:17.779Z
Learning: In the `InboxFilterWrapper` component, `optionsKey` should always be set to `"name"` because options are transformed and created within the component.
🪛 Biome (1.9.4)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js
[error] 74-74: Do not access Object.prototype method 'hasOwnProperty' from target object.
It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.
(lint/suspicious/noPrototypeBuiltins)
[error] 77-77: Do not access Object.prototype method 'hasOwnProperty' from target object.
It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.
(lint/suspicious/noPrototypeBuiltins)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PopInbox.js
[error] 272-272: Unnecessary use of boolean literals in conditional expression.
Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with
(lint/complexity/noUselessTernary)
🔇 Additional comments (19)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js (1)
179-179
: 🧹 Nitpick (assertive)Confirm existence of
facilityId.id
.When you pass
facilityId.id
into the request, ensure it won't raise a runtime error. For instance, iffacilityId
is accidentally set to a non-object, or if.id
is missing. Add an additional safety check or strong type validation.health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (1)
Line range hint
163-230
: Looks good overall.The conditional rendering and usage of
<Fragment>
to group extra filters appear consistent and clear. The references to the newfacilityId
property, state handling, and dropdown usage are aligned with the updated logic.health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PopInbox.js (17)
29-29
: Initialize filter state with an object.
Using an object for the default state is consistent with subsequent logic that relies on object properties. No concerns here.
284-284
: Conditional check for status.
Comparingstate.state
toselectedFilter?.status
is straightforward and correct for verifying a matching workflow state.
296-296
: No concerns with useEffect dependencies.
IncludingselectedFilter?.status
in the dependency array ensures the effect re-runs whenever the status changes.
427-429
: State setter does nothing.
Spreadingprev
without adding or removing properties leaves the state unchanged. Verify if this is intentional or if additional updates are needed.
436-436
: Assigning count based on status.
This line logically assigns the count for the current status; no specific concerns.
447-447
: Appropriate effect dependencies.
No issues observed; the dependency array is accurate for re-fetch logic.
450-450
: Clear condition for "VALIDATED" status.
The logic is consistent with your workflow. No issues.
462-462
: Dependency array includes status.
Ensures consistent re-render whenever status changes. Looks good.
464-464
: Filter handler.
This new function centralizes filter logic nicely. No issues.
472-477
: Merging filter values.
Using the spread operator is a clean way to merge incoming filter properties with existing ones.
643-643
: isEstimate prop usage.
No concerns or errors. This boolean prop is straightforward.
647-647
: defaultValue assignment.
ProvidingselectedFilter
here ensures filter UI stays in sync with state. No issues.
496-498
: Guard against empty activeFilter.
IfactiveFilter
is empty,Object.entries(activeFilter)?.[0]?.[0]
might be undefined. Consider a fallback to avoid unexpected state.
567-567
: Validation action condition is clear.
Checking if status is"PENDING_FOR_VALIDATION"
matches expected workflow. No points of concern.
570-570
: Approval action condition is consistent.
No issues with verifying"PENDING_FOR_APPROVAL"
before allowing"APPROVE"
or"ROOT_APPROVE"
.
573-573
: Send-back action condition is consistent.
No concerns here; logic is straightforward.
772-772
: Conditional styling based on status.
Applying different heights for"VALIDATED"
is minor but acceptable.
...h/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js
Show resolved
Hide resolved
...h/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js
Outdated
Show resolved
Hide resolved
...h/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js
Show resolved
Hide resolved
...ro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js
Show resolved
Hide resolved
...ro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js
Show resolved
Hide resolved
...th/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PopInbox.js
Show resolved
Hide resolved
...th/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PopInbox.js
Show resolved
Hide resolved
...th/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PopInbox.js
Show resolved
Hide resolved
...th/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PopInbox.js
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🔭 Outside diff range comments (2)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (1)
Line range hint
89-126
: Improve API configuration and error handling.
- Consider using a finite cache time to prevent stale data.
- Implement error handling for the API call.
const planFacilitySearchConfig = { // ... existing config config: { enabled: true, select: (data) => { + if (!data) { + console.error('No data received from facility search'); + return []; + } if (!data?.PlanFacility || !Array.isArray(data.PlanFacility)) return []; const facilityOptions = data.PlanFacility.map((facility) => ({ code: facility.facilityName, id: facility.facilityId })); return facilityOptions; }, - cacheTime: Infinity + cacheTime: 5 * 60 * 1000 // 5 minutes } }; +if (planFacilityerror) { + console.error('Error fetching facility data:', planFacilityerror); + // Consider showing an error message to the user +}health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js (1)
Line range hint
1-1199
: Consider splitting the component for better maintainability.The PlanInbox component has grown quite large and handles multiple responsibilities. Consider breaking it down into smaller, focused components:
- Filter management
- Table management
- Workflow actions
- API integration layer
This will improve maintainability and testability.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
health/micro-ui/web/micro-ui-internals/packages/css/package.json
is excluded by!**/*.json
📒 Files selected for processing (6)
health/micro-ui/web/micro-ui-internals/example/public/index.html
(1 hunks)health/micro-ui/web/micro-ui-internals/packages/css/src/components/microplan.scss
(1 hunks)health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js
(8 hunks)health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/RoleTableComposer.js
(0 hunks)health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js
(4 hunks)health/micro-ui/web/public/index.html
(1 hunks)
💤 Files with no reviewable changes (1)
- health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/RoleTableComposer.js
🧰 Additional context used
📓 Path-based instructions (2)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (1)
Pattern **/*.js
: check
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js (1)
Pattern **/*.js
: check
📓 Learnings (2)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (1)
Learnt from: Ramkrishna-egov
PR: egovernments/DIGIT-Frontend#1562
File: health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js:57-57
Timestamp: 2024-11-12T10:40:17.779Z
Learning: In the `InboxFilterWrapper` component, `optionsKey` should always be set to `"name"` because options are transformed and created within the component.
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js (1)
Learnt from: rachana-egov
PR: egovernments/DIGIT-Frontend#1847
File: health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js:308-314
Timestamp: 2024-11-18T04:35:51.535Z
Learning: In `PlanInbox.js`, the variable `planWithCensus?.StatusCount[selectedFilter]` is always defined in the given context, so null checks are unnecessary.
🪛 Biome (1.9.4)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js
[error] 208-211: Missing key property for this element in iterable.
The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.
(lint/correctness/useJsxKeyInIterable)
[error] 205-205: Use Number.parseInt instead of the equivalent global.
ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.
(lint/style/useNumberNamespace)
🔇 Additional comments (9)
health/micro-ui/web/micro-ui-internals/packages/css/src/components/microplan.scss (1)
541-542
: LGTM!The syntax error has been fixed by properly closing the
.gap-between-dropdowns
class with a closing brace.health/micro-ui/web/micro-ui-internals/example/public/index.html (1)
15-15
: Verify the updated CSS version exists.The CSS version has been updated from 0.2.33 to 0.2.34. Let's verify this version exists and contains the required PlanIbox and filtering styles.
✅ Verification successful
CSS version 0.2.34 is valid and contains the required styles
The updated version exists and includes comprehensive styling for microplan components and filtering functionality.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the existence and contents of the updated CSS version # Check if the new version exists on unpkg curl -s -o /dev/null -w "%{http_code}" https://unpkg.com/@egovernments/[email protected]/dist/index.css # Check if there are any PlanIbox or filtering related styles curl -s https://unpkg.com/@egovernments/[email protected]/dist/index.css | grep -i "plan\|filter"Length of output: 36606
health/micro-ui/web/public/index.html (1)
13-13
: LGTM! Version update is consistent.The CSS version update matches the change in the example template, maintaining consistency across the application.
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (3)
14-14
: Unify naming convention for facilityId.The state initialization uses
facilityID
(capital D) while the rest of the code referencesfacilityId
. This discrepancy can cause confusion or bugs.
19-27
: LGTM! Default options handling is well implemented.The code properly handles both null and non-null values while maintaining immutability.
215-215
: LGTM! Consistent usage of optionsKey.The code correctly uses
optionsKey="code"
for Dropdown components and maintains "name" for RadioButtons, following the established patterns.health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js (3)
36-36
: LGTM! State initialization looks good.The
facilityName
property is properly initialized as null in theselectedFilter
state object.
179-179
: LGTM! API integration is consistent.The
facilityName
filter is properly integrated into both search APIs using the spread operator with null checks.Also applies to: 220-221
888-888
: Verify the implementation ofisEstimate
prop.The
isEstimate
prop is passed to InboxFilterWrapper, but its implementation needs verification.Run this script to check the prop's usage in the InboxFilterWrapper component:
✅ Verification successful
✓ The
isEstimate
prop is properly implementedThe prop is correctly used to toggle the village road condition filter in InboxFilterWrapper, with consistent usage across PlanInbox (true) and PopInbox (false) components.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for isEstimate prop usage in InboxFilterWrapper ast-grep --pattern 'const $_ = $props.isEstimate' && \ ast-grep --pattern 'isEstimate={$_}' && \ ast-grep --pattern 'if ($props.isEstimate) { $$$ }'Length of output: 146
Script:
#!/bin/bash # Find InboxFilterWrapper component file fd InboxFilterWrapper # Search for any usage of isEstimate in the codebase rg "isEstimate" -A 3 -B 3 # Look for prop types or interface definitions ast-grep --pattern 'interface $_ { isEstimate$_?: $_ $$$ }'Length of output: 3176
health/micro-ui/web/micro-ui-internals/packages/css/src/components/microplan.scss
Show resolved
Hide resolved
health/micro-ui/web/micro-ui-internals/example/public/index.html
Outdated
Show resolved
Hide resolved
...ro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (2)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (2)
14-14
: 🧹 Nitpick (assertive)Maintain consistent naming convention for facility identifier
The state initialization uses
facilityName
while previous code usedfacilityId
. Consider aligning the naming convention across the codebase.-{ status: null, onRoadCondition: null, terrain: null, securityQ1: null, securityQ2: null,facilityName:null } +{ status: null, onRoadCondition: null, terrain: null, securityQ1: null, securityQ2: null, facilityId: null }
205-218
: 🛠️ Refactor suggestionFix React key, parsing, and translation key issues
Multiple improvements needed in the security questions mapping:
- Add key prop for React list rendering
- Use Number.parseInt for consistency
- Use underscore instead of space in translation key
- const questionNumber = parseInt(item.id, 10); + const questionNumber = Number.parseInt(item.id, 10); return ( <LabelFieldPair + key={`security-question-${questionNumber}`} vertical style={{ paddingBottom: isLastElement ? "1rem" : "0" }} > - <div className="custom-filter-names">{t(`MP_SECURITY_QUESTION ${index+1}`)}</div> + <div className="custom-filter-names">{t(`MP_SECURITY_QUESTION_${index + 1}`)}</div>🧰 Tools
🪛 Biome (1.9.4)
[error] 208-211: Missing key property for this element in iterable.
The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.(lint/correctness/useJsxKeyInIterable)
[error] 205-205: Use Number.parseInt instead of the equivalent global.
ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.(lint/style/useNumberNamespace)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js
(9 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (1)
Pattern **/*.js
: check
📓 Learnings (1)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (1)
Learnt from: Ramkrishna-egov
PR: egovernments/DIGIT-Frontend#1562
File: health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js:57-57
Timestamp: 2024-11-12T10:40:17.779Z
Learning: In the `InboxFilterWrapper` component, `optionsKey` should always be set to `"name"` because options are transformed and created within the component.
🪛 Biome (1.9.4)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js
[error] 208-211: Missing key property for this element in iterable.
The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.
(lint/correctness/useJsxKeyInIterable)
[error] 205-205: Use Number.parseInt instead of the equivalent global.
ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.
(lint/style/useNumberNamespace)
🔇 Additional comments (4)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (4)
1-1
: LGTM: Fragment import added correctlyThe Fragment import is properly added and used later in the code for wrapping multiple elements.
Line range hint
110-119
: Verify infinite cache time strategyWhile the facility mapping logic is correct, setting
cacheTime
toInfinity
might prevent updates to facility data from being reflected. Consider using a more appropriate cache duration based on how frequently facility data changes.
157-158
: LGTM: Fragment wrapper properly implementedThe Fragment is correctly used to wrap estimate-specific filters and properly conditioned with props.isEstimate.
Also applies to: 224-225
160-160
: LGTM: Consistent styling approach for filter labelsThe switch to div elements with custom-filter-names class provides better styling control and maintains consistency across all filter labels.
Also applies to: 172-172, 184-184
...ro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js
Outdated
Show resolved
Hide resolved
health/micro-ui/web/micro-ui-internals/example/public/index.html
Outdated
Show resolved
Hide resolved
...ro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js
Outdated
Show resolved
Hide resolved
...ro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js
Outdated
Show resolved
Hide resolved
...h/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js
Outdated
Show resolved
Hide resolved
...th/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PopInbox.js
Show resolved
Hide resolved
...th/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PopInbox.js
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (1)
health/micro-ui/web/micro-ui-internals/example/public/index.html (1)
15-15
: 🧹 Nitpick (assertive)Consider hosting CSS files locally for better reliability.
While using unpkg CDN is convenient, consider hosting these CSS files locally to:
- Reduce dependency on external services
- Improve load times
- Ensure version consistency
- Better control over asset availability
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
health/micro-ui/web/micro-ui-internals/packages/css/package.json
is excluded by!**/*.json
📒 Files selected for processing (5)
health/micro-ui/web/micro-ui-internals/example/public/index.html
(1 hunks)health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js
(8 hunks)health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js
(4 hunks)health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PopInbox.js
(14 hunks)health/micro-ui/web/public/index.html
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js (1)
Pattern **/*.js
: check
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PopInbox.js (1)
Pattern **/*.js
: check
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (1)
Pattern **/*.js
: check
📓 Learnings (2)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js (1)
Learnt from: rachana-egov
PR: egovernments/DIGIT-Frontend#1847
File: health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js:308-314
Timestamp: 2024-11-18T04:35:51.535Z
Learning: In `PlanInbox.js`, the variable `planWithCensus?.StatusCount[selectedFilter]` is always defined in the given context, so null checks are unnecessary.
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (1)
Learnt from: Ramkrishna-egov
PR: egovernments/DIGIT-Frontend#1562
File: health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js:57-57
Timestamp: 2024-11-12T10:40:17.779Z
Learning: In the `InboxFilterWrapper` component, `optionsKey` should always be set to `"name"` because options are transformed and created within the component.
🪛 Biome (1.9.4)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PopInbox.js
[error] 272-272: Unnecessary use of boolean literals in conditional expression.
Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with
(lint/complexity/noUselessTernary)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js
[error] 74-74: Do not access Object.prototype method 'hasOwnProperty' from target object.
It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.
(lint/suspicious/noPrototypeBuiltins)
[error] 77-77: Do not access Object.prototype method 'hasOwnProperty' from target object.
It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.
(lint/suspicious/noPrototypeBuiltins)
[error] 215-218: Missing key property for this element in iterable.
The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.
(lint/correctness/useJsxKeyInIterable)
[error] 212-212: Use Number.parseInt instead of the equivalent global.
ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.
(lint/style/useNumberNamespace)
🔇 Additional comments (13)
health/micro-ui/web/micro-ui-internals/example/public/index.html (1)
15-15
: Verify version consistency with package dependenciesThe CSS version has been updated to 0.2.36. Please ensure this version is consistent with the package.json dependencies.
✅ Verification successful
Version consistency verified ✓
The CSS version 0.2.36 used in the CDN URL matches exactly with the package version in
health/micro-ui/web/micro-ui-internals/packages/css/package.json
.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Check if the version in package.json matches the CDN version fd package.json | xargs cat | jq -r '.dependencies["@egovernments/digit-ui-health-css"]'Length of output: 280
Script:
#!/bin/bash # Search for any mention of digit-ui-health-css in package.json files rg -A 5 -B 5 "digit-ui-health-css" $(fd package.json)Length of output: 2819
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (7)
14-14
: Maintain consistent naming for facilityId.The state initialization uses
facilityID
(capital D) while the rest of the code referencesfacilityId
. This inconsistency can lead to bugs.Apply this diff to maintain consistency:
- { status: null, onRoadCondition: null, terrain: null, securityQ1: null, securityQ2: null,facilityID:null } + { status: null, onRoadCondition: null, terrain: null, securityQ1: null, securityQ2: null, facilityId: null }
19-29
: LGTM! Clean implementation of facilityId default value handling.The special case handling for
facilityId
is well-implemented, maintaining the code's structure while adding the new functionality.
37-39
: LGTM! Clean implementation of facilityId state update.The useEffect hook correctly handles the
facilityId
case by only setting the code without the name property.
74-77
: Use Object.hasOwn() for safer property checks.Using
hasOwnProperty
directly on objects can be unsafe if the object's prototype is altered. UseObject.hasOwn()
instead.Apply this diff to improve security:
-if(filterValues[key] && typeof filterValues[key] === 'object' && String(key)==='facilityId' &&filterValues[key].hasOwnProperty('code') ){ +if(filterValues[key] && typeof filterValues[key] === 'object' && String(key)==='facilityId' && Object.hasOwn(filterValues[key], 'code')) { filtersToApply[key] = filterValues[key] } -else if (filterValues[key] && typeof filterValues[key] === 'object' && filterValues[key].hasOwnProperty('code')) { +else if (filterValues[key] && typeof filterValues[key] === 'object' && Object.hasOwn(filterValues[key], 'code')) { filtersToApply[key] = filterValues[key].code; }🧰 Tools
🪛 Biome (1.9.4)
[error] 74-74: Do not access Object.prototype method 'hasOwnProperty' from target object.
It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.(lint/suspicious/noPrototypeBuiltins)
[error] 77-77: Do not access Object.prototype method 'hasOwnProperty' from target object.
It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.(lint/suspicious/noPrototypeBuiltins)
191-199
: Add key prop to LabelFieldPair.React requires a key prop when rendering elements in a list to help with efficient updates.
Apply this diff:
-<LabelFieldPair vertical> +<LabelFieldPair vertical key="facility-filter"> <div className="custom-filter-names">{t("MP_FILTER_FACILITY")}</div> <Dropdown option={planFacility} optionKey={"code"} selected={filterValues["facilityId"] || defaultSelectedOptions?.facilityId } select={(value) => handleDropdownChange("facilityId", value)} t={t} disabled={false} /> </LabelFieldPair>
212-225
: Improve security questions implementation.
- Use
Number.parseInt
instead of globalparseInt
for consistency with ES2015.- Avoid spaces in translation keys.
Apply this diff:
-const questionNumber = parseInt(item.id, 10); +const questionNumber = Number.parseInt(item.id, 10); -<div className="custom-filter-names">{t(`MP_SECURITY_QUESTION ${index + 1}`)}</div> +<div className="custom-filter-names">{t(`MP_SECURITY_QUESTION_${index + 1}`)}</div>🧰 Tools
🪛 Biome (1.9.4)
[error] 215-218: Missing key property for this element in iterable.
The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.(lint/correctness/useJsxKeyInIterable)
[error] 212-212: Use Number.parseInt instead of the equivalent global.
ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.(lint/style/useNumberNamespace)
Line range hint
164-232
: LGTM! Clean implementation of conditional rendering.The
isPlanInbox
prop is used correctly to conditionally render the filter options.🧰 Tools
🪛 Biome (1.9.4)
[error] 215-218: Missing key property for this element in iterable.
The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.(lint/correctness/useJsxKeyInIterable)
[error] 212-212: Use Number.parseInt instead of the equivalent global.
ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.(lint/style/useNumberNamespace)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PopInbox.js (2)
29-29
: LGTM! Clean state initialization.The initial state is well-structured with a meaningful default value for the status.
472-477
: LGTM! Clean filter state update.The filter state update correctly preserves existing state while applying new values.
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js (3)
36-36
: LGTM! Clean state initialization with facilityId.The initial state correctly includes
facilityId
with a null value.
179-180
: LGTM! Consistent facility filter implementation.The facility-based filtering is implemented consistently across both API calls.
Also applies to: 220-221
Line range hint
888-892
: LGTM! Correct usage of isPlanInbox prop.The InboxFilterWrapper is correctly configured with the
isPlanInbox
prop.
* PopInbox and facilityId search in planInbox * Localization * Chages to CSS and removing filter * Changes to facility filter and security Question * css package update * facilityId removed * Resolved comments, made payload to facilityId * component package update
FEATURE/HCMPRE-1713: PlanIbox and filtering integration
Summary by CodeRabbit
New Features
Bug Fixes
Refactor